package arrayList;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;

class Card {

    public String suit; //花色
    public String rank; //点数

    public Card(String suit, String rank) {
        this.suit = suit;
        this.rank = rank;
    }

    public String toString() {
        return "(" + suit + rank + ")";
    }

}

public class TestCard {

    public static ArrayList<Card> createdeck() {
        ArrayList<Card> deck = new ArrayList<>();

        String[] suits = {"♥","♠","♣","♦"};
        for (String suit : suits) {
            for (int i = 2;i <= 10;i++) {
                Card card = new Card(suit,"" + i);
                deck.add(card);
            }
            deck.add(new Card(suit,"J"));
            deck.add(new Card(suit,"Q"));
            deck.add(new Card(suit,"K"));
            deck.add(new Card(suit,"A"));
        }
        return deck;
    }

    public static void main(String[] args) {
//        Card card = new Card("♥","A");
//        System.out.println(card);
        ArrayList<Card> deck = createdeck();
        System.out.println(deck);

        Collections.shuffle(deck);
        System.out.println("洗牌后" + deck);

        ArrayList<ArrayList<Card>> players = new ArrayList<>();

        for (int i = 0;i < 3;i++) {
            players.add(new ArrayList<>());
        }

        for (int round = 0;round < 5;round++) {
            for (int i = 0;i < 3;i++) {
                Card card = deck.remove(0);
                ArrayList<Card> player = players.get(i);
                player.add(card);
            }
        }

        for (int i = 0;i < 3;i++) {
            ArrayList<Card> player = players.get(i);
            System.out.println("玩家" + (i + 1) + ":" + player);
        }
    }
}
